package com.hello.web.controller;

import com.hello.common.aspect.ApiOperationLog;
import com.hello.common.utils.PageResponse;
import com.hello.common.utils.Response;
import com.hello.web.domain.bo.user.AddUserBO;
import com.hello.web.domain.bo.user.DelUserBO;
import com.hello.web.domain.bo.user.UserQueryBO;
import com.hello.web.domain.entity.UserDO;
import com.hello.web.service.user.UserService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 
 * @date 2025/2/24 15:23
 */
@RestController
@RequestMapping("/user")
@RequiredArgsConstructor
//@SaCheckPermission("user")
public class UserController {

    private final UserService userService;

    @PostMapping("/page/list")
    @ApiOperation(value = "分页用户列表")
    @ApiOperationLog(description = "用户列表")
    public PageResponse queryUserPageList(@RequestBody @Validated UserQueryBO bo) {
        return userService.queryUserPageList(bo);
    }

    @PostMapping("/list")
    @ApiOperation(value = "用户列表")
    @ApiOperationLog(description = "用户列表")
    public Response queryUserList() {
        return userService.queryUserList();
    }

    @PostMapping("/add")
    @ApiOperation(value = "新增用户")
    @ApiOperationLog(description = "新增用户")
    public Response<UserDO> addUser(@RequestBody @Validated AddUserBO bo) {
        return Response.success(userService.addUser(bo));
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除用户")
    @ApiOperationLog(description = "删除用户")
    public Response deleteUser(@RequestBody @Validated DelUserBO bo) {
        userService.deleteUser(bo);
        return Response.success();
    }
}
